Optimizer: don't inline named functions in debug builds#19548
Optimizer: don't inline named functions in debug builds#19548auduchinok wants to merge 11 commits intodotnet:mainfrom
Conversation
❗ Release notes required
|
ed866e5 to
d607132
Compare
bb4fe70 to
9377496
Compare
9377496 to
257c702
Compare
|
re: Debugging I would rely on people choosing to do "Just My Code" or not, in general. I would assume most of the "ugly to debug" fslib code uses statically optimized switches and is forced to be inlined even after this feature? |
Yes, IDE settings is going to be the primary way to control it. The problem is when an SRTP function from another assembly gets a specialized definition, the resulting method becomes a part of the user assembly. That's the reason I'm considering adding an attribute like
I'm considering keeping inlining for functions in these modules:
That would allow to workaround the issue with |
|
I've checked all |
|
Ok, how do you want to whitelist those? I agree with the selection, there is nothing surprising inside of those module's functions. For the specialized SRTP definition, wouldn't |
I'm going to try the second approach first, so it could work with older FSharp.Core too. |
8049b31 to
a48fa0e
Compare
a48fa0e to
0c16c35
Compare
5cc1c28 to
1a0b4d6
Compare
1a0b4d6 to
e5e7134
Compare
inlinefunctions are fully inlined on the call sites by F# compiler. This means the source information and actual calls are lost, so it's very hard to reliably debug code using such functions.This PR prevents inlining
inlinefunctions in debug builds. This improves debugging experience by allowing setting breakpoints inside such functions and allowing stepping into them and checking the function arguments. It also allows IDEs to analyze the produced IL more reliably during debug.The implementation handles two distinct cases. When possible, a normal call to the existing method is emitted. When a function contains SRTPs and no callable method is produced, a specialized method is created for each type instantiation.
An example
inlinefunction that can be called directly:The existing method is called:

An
inlinefunction with SRTPs:A specialized method is produced and called:

Open questions:
DebuggerNonUserCode?Implements fsharp/fslang-suggestions#824 for debug builds.
Fixes #9555.